package com.rickpan.dto.openrouter;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

/**
 * OpenRouter API请求DTO
 */
public class OpenRouterRequest {

    private String model;
    private List<OpenRouterMessage> messages;
    private boolean stream = true;
    
    @JsonProperty("max_tokens")
    private Integer maxTokens;

    // 构造函数
    public OpenRouterRequest() {}

    public OpenRouterRequest(String model, List<OpenRouterMessage> messages) {
        this.model = model;
        this.messages = messages;
    }

    // Builder模式
    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private String model;
        private List<OpenRouterMessage> messages;
        private boolean stream = true;
        private Integer maxTokens;

        public Builder model(String model) {
            this.model = model;
            return this;
        }

        public Builder messages(List<OpenRouterMessage> messages) {
            this.messages = messages;
            return this;
        }

        public Builder stream(boolean stream) {
            this.stream = stream;
            return this;
        }

        public Builder maxTokens(Integer maxTokens) {
            this.maxTokens = maxTokens;
            return this;
        }

        public OpenRouterRequest build() {
            OpenRouterRequest request = new OpenRouterRequest();
            request.model = this.model;
            request.messages = this.messages;
            request.stream = this.stream;
            request.maxTokens = this.maxTokens;
            return request;
        }
    }

    // Getter 和 Setter 方法
    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public List<OpenRouterMessage> getMessages() {
        return messages;
    }

    public void setMessages(List<OpenRouterMessage> messages) {
        this.messages = messages;
    }

    public boolean isStream() {
        return stream;
    }

    public void setStream(boolean stream) {
        this.stream = stream;
    }

    public Integer getMaxTokens() {
        return maxTokens;
    }

    public void setMaxTokens(Integer maxTokens) {
        this.maxTokens = maxTokens;
    }

    @Override
    public String toString() {
        return "OpenRouterRequest{" +
                "model='" + model + '\'' +
                ", messages=" + messages +
                ", stream=" + stream +
                ", maxTokens=" + maxTokens +
                '}';
    }
}
